//
//  UIView+Gesture.m
//  homework
//
//  Created by panxiang on 14-5-8.
//  Copyright (c) 2014年 Baidu. All rights reserved.
//

#import "UIView+Gesture.h"

@implementation UIView (Gesture)

- (UITapGestureRecognizer *)addTapGestureWithTarget:(id)target selector:(SEL)selector
{
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:target action:selector];
    tap.delegate = target;
    [self addGestureRecognizer:tap];
    return tap;
}

- (UIPanGestureRecognizer *)addPanGestureWithTarget:(id)target selector:(SEL)selector
{
    UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:target action:selector];
    [self addGestureRecognizer:pan];
    return pan;
}

- (UILongPressGestureRecognizer *)addLongPressGestureWithTarget:(id)target selector:(SEL)selector
{
    UILongPressGestureRecognizer *press = [[UILongPressGestureRecognizer alloc] initWithTarget:target action:selector];
    press.delegate = target;
    [self addGestureRecognizer:press];
    return press;
}

- (void)removeAllGesture{
    for (UIGestureRecognizer* gesture in self.gestureRecognizers) {
        gesture.delegate = nil ;
        gesture.enabled = NO;
    }
}
@end
